package map;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
        String line = "Thanking in java!i love java!";
        Map<Character, Integer> map = new HashMap<>();
        /*
        for (int i = 0; i < line.length(); i++) {

            char c = line.charAt(i);
            if (map.containsKey(c)) {
                int sum = map.get(c);
                sum ++;
                map.put(c, sum);
            } else {
                map.put(c, 1);
            }
        }
        System.out.println(map);
        */
        for (int i = 0; i < line.length(); i++){
            char c = line.charAt(i);
            int num = map.containsKey(c)?map.get(c)+1:1;
            map.put(c,num);
        }
        System.out.println(map);
    }
}

